package com.repository;

import com.domain.DoorCar;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface CarRepo extends JpaRepository<DoorCar,Long> {
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value = "update door_car p set p.model =?1 where p.department = ?2",nativeQuery = true)
    void updateByName(String model,String department);

    DoorCar findByDepartment(String department);

    @Modifying(clearAutomatically = true)
    @Query(value = "update door_car p set p.model =?1,p.department=?2,p.name=?3,p.starttime=?4,p.stoptime=?5 where p.id = ?6",nativeQuery = true)
    int updateDoorCarById(String model,String department,String name,String starttime,String stoptime,int id);

}
